package com.lc.controller;

import com.lc.pojo.param.PmsSpuParam;
import com.lc.result.Result;
import com.lc.result.ResultUtils;
import com.lc.service.*;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 商品
 */

@RestController
@RequestMapping("/pms/product")
public class pmsProductController {

    @Resource
    private PPCService ppcService;

    @Resource
    private PPAService ppaService;

    @Resource
    private PmsBrandService pmsBrandService;

    @Resource
    private PmsSpuService pmsSpuService;

    @Resource
    private PmsSkuService pmsSkuService;

    //查询所有商品分类列表接口
    @GetMapping("/category/list")
    public Result categoryList(){
        return ResultUtils.returnDataSuccess(ppcService.getClassifyPPC());
    }

    //根据商品二级分类ID查询商品属性列表接口
    @PostMapping("/attribute/byCategoryIds")
    public Result byCategoryIds(){
        return ResultUtils.returnDataSuccess(ppaService.getAttribute());
    }

    //查询所有商品属性列表接口
    @GetMapping("/attribute/list")
    public Result attributeList(){
        return ResultUtils.returnDataSuccess(ppaService.getAttribute());
    }

    //查询所有商品品牌列表接口
    @GetMapping("/brand/list")
    public Result brandList(){
        return ResultUtils.returnDataSuccess(pmsBrandService.getBrandList());
    }

    //商品搜索接口** && 首页商品列表接口 && 商品详情页热门商品排行接口
    @PostMapping("/search")
    public Result search(@RequestBody PmsSpuParam psp) {
        return ResultUtils.returnDataSuccess(pmsSpuService.getPmsSpuList(psp));
    }

    //查看商品详情接口
    @GetMapping("/detail")
    public Result detail(Integer spuId){
        return ResultUtils.returnDataSuccess(pmsSkuService.getPmsSkuDetail(spuId));
    }

}
